<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="com.pojo.system.COMP" %>
<%
	String username =(String) session.getAttribute("username");
	if(username != null && !username.equals("")){
		response.sendRedirect("index.jsp");
	}
	List<COMP> listComp = (List<COMP>)session.getAttribute("listComp");
	if(listComp == null ){
		//request.getRequestDispatcher("compAction.findAllDataByLogin.action").forward(request, response);
		response.sendRedirect("compAction.findAllDataByLogin.action");
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>GTC</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="jquery/jquery-1.5.1.js"></script>
<script type="text/javascript">
function checkData()
{
	$.ajax({
		async:false,
		cache:false
	});	
	var username = $("#username").val();
	var pwd = $("#pwd").val();
	var compno = $("#compno").val();
	if($.trim(username)==""){
		alert("用戶名不能為空!");
		return false;
	} 
	/**if($.trim(pwd)==""){
		alert("密碼不能為空!");
		return false;
	} */
	$("#show").css("display","block");
	$.get('pswdAction.ajaxLogin.action',{'pswdVo.usr':""+username,'pswdVo.pwd':""+pwd,'pswdVo.compno':""+compno,'timestamp':""+(new Date())},function(data) {
		  //alert($.trim(data));
		  if($.trim(data)=="error"){
			$("#show").html("<font color=red size='5'>用戶名或者密碼錯誤!</font>");
		  	return false;
		  }else{
			location.href="index.jsp";
		  }
	});
	return true;
}
</script>
</head>

<body bgcolor="#ffffff" text="#000000">
<form name="loginForm" method="post">
	<table align="center" width="96%" cellpadding="4" cellspacing="0">
		<tr>
			<td colspan="2">
				<div align="center">
					<img src="images/GTC.JPG">
				</div></td>
		</tr>
		<tr>
			<td colspan="2">
				<div id="show" style="display: none;" align="center">
					<img alt="" src="images/loading2.gif">&nbsp;&nbsp;&nbsp;&nbsp;<font
						color="red">正在验证......</font>
				</div></td>
		</tr>
		<tr>
			<td width="35%">
				<div align="right">
					<font face="Arial, Helvetica, sans-serif" size="2"> <SPAN><b>公司帳套&nbsp;:&nbsp;</b>
					</SPAN> </font>
				</div></td>
			<td><select name="compno" id="compno">
				<%
					if(listComp != null){
					for(COMP comp : listComp){
				%>
				<option value='<%= comp.getId().getCompno() %>'><%= comp.getName() %></option>
				<%
					}}
				%>
			</select></td>
		</tr>
		<tr>
			<td width="35%">
				<div align="right">
					<font face="Arial, Helvetica, sans-serif" size="2"> <SPAN><b>帳號&nbsp;:&nbsp;</b>
					</SPAN> </font>
				</div></td>
			<td><input type="text" name="username" size="42" value=""
				id="username"> <input type="hidden" name="job_no" size="42"
				value=""></td>
		</tr>
		<tr>
			<td>
				<div align="right">
					<font face="Arial, Helvetica, sans-serif" size="2"><SPAN><b>密碼&nbsp;:&nbsp;</b>
					</SPAN> </font>
				</div></td>

			<td><font face="Arial, Helvetica, sans-serif" size="2">
					<input type="password" name="pwd" size="20" id="pwd">
					&nbsp; <input type="button" value=" ENTER " onclick="checkData()">
					&nbsp; <input type="reset" name="Reset" value=" CLEAR "> </font>
				<SPAN>&nbsp;&nbsp; <a href="#">忘記密碼?</a> </SPAN></td>

		</tr>

		<tr>

			<td colspan="2">&nbsp;</td>

		</tr>

		<tr>

			<td colspan="2">&nbsp;</td>

		</tr>

		<tr>

			<td colspan="2" align="center"><font
				face="Arial, Helvetica, sans-serif" size="2"> Copyright
					&copy; 2011 - 2011 <b> We deliver core messages in seconds</b> (<font
					color="blue">GT2011-GT-V11.07.21-01</font>) </font></td>

		</tr>
		<tr>
			<td colspan="2">

				<div align="center">
					<SPAN> <a href="mailto:service@corepress.com.tw">E-mail
							: peterpeng@gtcontact.com</a> </SPAN>
				</div>
			</td>
		</tr>
	</table>
</form>
</body>

</html>
